package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.ProductInfo;
import cn.wolfcode.crm.mapper.ProductInfoMapper;
import cn.wolfcode.crm.query.ProductInfoQueryObject;
import cn.wolfcode.crm.service.IProductInfoService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductInfoServiceImpl implements IProductInfoService {

    @Autowired
    private ProductInfoMapper productInfoMapper;
    public void deleteByPrimaryKey(Long id) {
        productInfoMapper.deleteByPrimaryKey(id);
    }

    public void insert(ProductInfo record) {
        productInfoMapper.insert(record);
    }

    public ProductInfo selectByPrimaryKey(Long id) {
        return productInfoMapper.selectByPrimaryKey(id);
    }

    public List<ProductInfo> selectAll() {
        return productInfoMapper.selectAll();
    }

    public void updateByPrimaryKey(ProductInfo record) {
        productInfoMapper.updateByPrimaryKey(record);
    }

    public PageResult query(ProductInfoQueryObject qo) {
        int total = productInfoMapper.queryFormCount(qo);
        if(total == 0){
            return new PageResult();
        }
        List<ProductInfo> list = productInfoMapper.queryFormList(qo);
        return new PageResult(total,list);
    }

    public void changeSate(Long id) {
        productInfoMapper.changeSate(id);
    }

    public void shutDeduc(Long id) {
        productInfoMapper.shutDeduc(id);
    }

    public List<ProductInfo> queryProductForaiId(Long id) {
        return productInfoMapper.queryProductForaiId(id);
    }

    public List<String> selectProductName() {
        return productInfoMapper.selectProductName();
    }
}
